package likou;

/**
 * @author: 唐小尊
 * @email: 1171702529@qq.com
 * @cate: 2021/03/09 06:40
 */
public class _1047 {
    public String removeDuplicates(String S) {
        StringBuilder sb = new StringBuilder();
        byte[] ssb = S.getBytes();
        for (byte b : ssb) {
            if (sb.length() > 0) {
                if (sb.charAt(sb.length() - 1) == (char) b) {
                    sb.deleteCharAt(sb.length() - 1);
                }else{
                    sb.append((char) b);
                }
            } else {
                sb.append((char) b);
            }
        }
        return sb.toString();
    }
}
